//
//  UIButton+ConvenientBtn.m
//  链式编程
//
//  Created by apple on 2017/9/4.
//  Copyright © 2017年 apple. All rights reserved.
//

#import "UIButton+ConvenientBtn.h"

@implementation UIButton (ConvenientBtn)

- (UIButton *(^)(NSString *))wt_titleLabel{

    return ^(NSString *value){
    
        [self setTitle:value forState:UIControlStateNormal];
        
        return self;
    };
}


- (UIButton *(^)(int))wt_titleFont{

    return ^(int value){
        
        self.titleLabel.font = [UIFont systemFontOfSize:value];
        
        return self;
    };
}


- (UIButton *(^)(NSString *))wt_titleAlignment{

    return ^(NSString *alignment){
        
        if ([alignment isEqualToString:@"L"]) {
            
            self.contentHorizontalAlignment = NSTextAlignmentLeft;
            
        }else if ([alignment isEqualToString:@"R"]){
            
            self.contentHorizontalAlignment = NSTextAlignmentRight;
            
        }else{
            
            self.contentHorizontalAlignment = NSTextAlignmentCenter;
        }
        
        return self;
    };
}


- (UIButton *(^)(int))wt_cornerRadius{

    return ^(int value){
    
        self.layer.cornerRadius = value;
        
        return self;
    };
}


- (UIButton *(^)(int, int, int))wt_bgColor{
    
    return ^(int R, int G, int B){
        
        self.backgroundColor = [UIColor colorWithRed:R/255.0 green:G/255.0 blue:B/255.0 alpha:1];
        
        return self;
    };
}


- (UIButton *(^)(int, int, int))wt_titleColor{
    
    return ^(int R, int G, int B){
        
        [self setTitleColor:[UIColor colorWithRed:R/255.0 green:G/255.0 blue:B/255.0 alpha:1] forState:UIControlStateNormal];
        
        return self;
    };
}

@end
